package com.iking.housekeeping.service.servicetype;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.iking.housekeeping.common.PageParam;
import com.iking.housekeeping.dao.servicetype.ServiceTypeMapper;
import com.iking.housekeeping.entity.servicetype.ServiceType;
import com.iking.housekeeping.httpbean.servicetype.reqbean.ServiceMenu;
import com.iking.housekeeping.util.UUIDUtil;

/**
 * 服务类型信息
 * 
 * @author: gf
 * @date: 2018年4月18日 下午7:13:48
 */
@Service
public class ServiceTypeService {
	
	/**
	 * 服务类型记录
	 */
	@Autowired
	private ServiceTypeMapper serviceTypeMapper;	
	
	/**
	 * 	添加
	 *  @param req
	 *  @return int
	 *  @author gf
	 */
	public int insert(ServiceType req) {
		req.setfIsDelete(false);
		req.setfId(UUIDUtil.getUUID());
		return serviceTypeMapper.insertSelective(req);
	}
	
	/**
	 * 	删除
	 *  @param fId	删除的ID
	 *  @return ReturnCode
	 *  @author gf
	 */
	public int delete(List<String> fIds) {
		
		return serviceTypeMapper.updateByFidPrimaryKey(fIds);
	}
	
	/**
	 * 	更新
	 *  @param req
	 *  @return int
	 *  @author gf
	 */
	public int update(ServiceType req) {
		return serviceTypeMapper.updateByPrimaryKeySelective(req);
	}
	
	/**
	 * 	分页查询所有服务类型
	 *  @param pageParam
	 *  @return Page<ServiceType>
	 *  @author gf
	 */
	public Page<ServiceType> selectByPage(PageParam pageParam){
		PageHelper.startPage(pageParam.getPageCurrent(), pageParam.getPageSize());
		return serviceTypeMapper.selectAll();
		 
	}
	/**
	 * 	通过属性查询对象
	 *  @param req
	 *  @return ServiceType
	 *  @author gf
	 */
	public ServiceType selectRepeat(ServiceType req) {
		return serviceTypeMapper.selectRepeat(req);
	}
	
	/**
	 * 	服务内容下拉列表
	 *  @return List<ServiceMenu>
	 *  @author gf
	 */
	public List<ServiceMenu> selectServiceMenu(){
		return serviceTypeMapper.selectServiceMenu();
	}
}
